package array

import "fmt"

/*
交换元素
temp = a
a = b
b = temp
*/
func BubbleSort(nums []int) {
	numsL := len(nums)

	for i := 0; i < numsL; i++ {
		for j := 0; j < numsL-i-1; j++ {
			if nums[j] > nums[j+1] {
				temp := nums[j]
				nums[j] = nums[j+1]
				nums[j+1] = temp
			}
		}
	}

}

func TwoPointTraverse(nums []int) {
	for i, j := 0, len(nums)-1; i <= j; {
		if i != j {
			fmt.Println(nums[i], nums[j])
		} else {
			fmt.Println(nums[i])
		}
		i++
		j--
	}
}

func MoveForward(nums []int) {
	for i := 0; i < len(nums)-1; i++ {
		nums[i] = nums[i+1]
	}
}
